﻿function SetDayList(dayId, monthId, yearId) {
    var month = $("#" + monthId).val();
    var year = $("#" + yearId).val();
    var day = $("#" + dayId).val();

    if ((month != -1) && (year != -1)) {
        var dayInMonth = new Date(year, month, 0).getDate();

        var dayList = $("#" + dayId);
        dayList.empty();
        dayList.append(
                            $('<option/>')
                            .attr('value', "-1")
                            .text("(day)")
                            );
        for (var i = 1; i <= dayInMonth; i++) {
            dayList.append(
                            $('<option/>')
                            .attr('value', String(i))
                            .text(("0" + String(i)).slice(-2))
                            );
            if (day == String(i))
                dayList.val(day);
        }

    }
}